var areacode = localStorage.getItem("areaCode"),
    areaname = localStorage.getItem("areaName");
$(".city").text("当前选择城市: "+areaname);
function getPro(areaCode){
    $.ajax({
        url: "http://118.25.235.213:8080/sms/tBProductgroupController.do?getCatagory&areaCode="+ areaCode +"&date=",
        type: "GET",
        dataType: "json", 
        success: function(data) {
              console.log(data);
              var tab1content = document.querySelector("#tab1"),
                  tab1contentHtml = "<div class=\"gsxw1\"><span>"+ data[0].name +"</span></div>" +
                                "<div class=\"diyi\"><img src=\"uploads/allimg/180420/1-1P420144Q90-L.jpg\" title=\"田园综合体项目的试点立项条件\" width=\"185\" height=\"100\" style=\"margin-left: 60px;\"/><a style=\"display: none\" href=\javascript:void(0)\">南岸农贸市场</a>" +
                                "<p style=\"display: none\" title=\"财政部日前下发《关于开展田园综合体建设试点工作的通知》，2017年，财政部...\">财政部日前下发《关于开展田园综合体建设试点工作的通知》，2017年，财政部...</p>" +
                                "</div>";
                  tab1content.innerHTML = tab1contentHtml;
                  $.ajax({
                    url: "http://118.25.235.213:8080/sms/tBProductgroupController.do?getPrudctsByGroupId&groupId=" + data[0].productGroupChildren[0].id,
                    type: "GET",
                    dataType: "json", 
                    success: function(childata) {
                          console.log(childata);
                          tab1contentHtml += "<div class=\"xw_list\" style=\"height: 189px; overflow-y: hidden; overflow-x: hidden;\">" +
                                         "<ul style=\"overflow-x: hidden;overflow-y: auto;height: 185px; width: 322px;\">" + 
                                         "<li><a href=\"http://118.25.235.213:8080/PWebService/html/"+ childata[0].folderName + "/" + childata[0].id +".html\" target=\"_blank\" title=\""+ childata[0].productName +"\">"+ childata[0].productName +"</a><span>"+ dateProcess(childata[0].createDate) +"</span></li>" +
                                         "<li><a href=\"http://118.25.235.213:8080/PWebService/html/"+ childata[1].folderName + "/" + childata[1].id +".html\" target=\"_blank\" title=\""+ childata[1].productName +"\">"+ childata[1].productName +"</a><span>"+ dateProcess(childata[1].createDate) +"</span></li>" +
                                         "<li><a href=\"http://118.25.235.213:8080/PWebService/html/"+ childata[2].folderName + "/" + childata[2].id +".html\" target=\"_blank\" title=\""+ childata[2].productName +"\">"+ childata[2].productName +"</a><span>"+ dateProcess(childata[2].createDate) +"</span></li>" +
                                         "<li><a href=\"http://118.25.235.213:8080/PWebService/html/"+ childata[0].folderName + "/" + childata[0].id +".html\" target=\"_blank\" title=\""+ childata[0].productName +"\">"+ childata[0].productName +"</a><span>"+ dateProcess(childata[0].createDate) +"</span></li>" +
                                         "<li><a href=\"http://118.25.235.213:8080/PWebService/html/"+ childata[1].folderName + "/" + childata[1].id +".html\" target=\"_blank\" title=\""+ childata[1].productName +"\">"+ childata[1].productName +"</a><span>"+ dateProcess(childata[1].createDate) +"</span></li>" +
                                         "<li><a href=\"http://118.25.235.213:8080/PWebService/html/"+ childata[2].folderName + "/" + childata[2].id +".html\" target=\"_blank\" title=\""+ childata[2].productName +"\">"+ childata[2].productName +"</a><span>"+ dateProcess(childata[2].createDate) +"</span></li>" +
                                         "<li><a href=\"http://118.25.235.213:8080/PWebService/html/"+ childata[0].folderName + "/" + childata[0].id +".html\" target=\"_blank\" title=\""+ childata[0].productName +"\">"+ childata[0].productName +"</a><span>"+ dateProcess(childata[0].createDate) +"</span></li>" +
                                         "<li><a href=\"http://118.25.235.213:8080/PWebService/html/"+ childata[1].folderName + "/" + childata[1].id +".html\" target=\"_blank\" title=\""+ childata[1].productName +"\">"+ childata[1].productName +"</a><span>"+ dateProcess(childata[1].createDate) +"</span></li>" +
                                         "<li><a href=\"http://118.25.235.213:8080/PWebService/html/"+ childata[2].folderName + "/" + childata[2].id +".html\" target=\"_blank\" title=\""+ childata[2].productName +"\">"+ childata[2].productName +"</a><span>"+ dateProcess(childata[2].createDate) +"</span></li>" +
                                         "</ul>" +
                                         "</div>";
                          tab1content.innerHTML = tab1contentHtml;               
                    }
                });                      
        }
    });
}
getPro(areacode);

function dateProcess(date){ //产品时间戳处理
    var time = new Date(date),
        timeyear = time.getFullYear(),
        timemonth = time.getMonth()+1,
        timeday = time.getDate();
        if( timemonth < 10 ){
            timemonth = "0" + timemonth;
        }
        if( timeday < 10 ){
            timeday = "0" + timeday;
        }
        timeyear = ""+timeyear;
        timeyear = timeyear.substring(2);
        return timeyear+"-"+timemonth+"-"+timeday;
}